<!--
Copyright 2018 Google LLC. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================
-->

<!doctype html>
<head>
    <link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.cyan-teal.min.css" />
</head>

<style>
  body {
    font-family: "Roboto", "Helvetica", "Arial", sans-serif;
    margin-top: 50px;
    margin-left: 50px;
    width: 80%;
  }
  .canvases {
    display: inline-block;
  }
  .monospace {
    font-family: monospace;
  }
  .input-title {
    display: inline-block;
    width: 20em;
  }
  .vertical-sections {
    border: 1px solid #AAA;
    padding: 6px;
    margin: 6px;
  }
  .horizontal-sections {
    display: inline-block;
    padding-right: 20px;
    vertical-align: top;
  }
  #app-status {
    color: blue;
    font-size: 150%;
    padding-bottom: 1em;
  }
  select {
    font-size: 14pt;
  }
  button {
    font-size: 14pt;
    margin: 3px;
  }
  input:disabled {
    background: #eeeeee;
  }
  textarea {
    width:98%;
  }
</style>

<body>
  <h1>TensorFlow.js Example:<br/>Train LSTM to Generate Text</h1>
  <div>
    <div id="app-status" class="vertical-sections">
      <span>Please select a text data source or enter your custom text in the text box below and click "load text data" first</span>
    </div>

    <div class="vertical-sections">
      <select id="text-data-select"></select>
      <button id="load-text-data">Load text data</button>
      <div>
        <textarea class="monospace" id="test-text" value="" rows="10"></textarea>
      </div>
    </div>

    <div class="vertical-sections">
      <div class="monospace">
        <span class="input-title">Model saved in IndexedDB:</span>
        <input class="monospace" id="model-available" readonly="true" size="60" value="(Load text data first.)"></input>
      </div>
      <div class="horizontal-sections">
        <div class="monospace">
          <span class="input-title">LSTM layer size(s)<br/>(e.g., 128 or 100,50):</span>
          <input class="monospace" id="lstm-layer-sizes" value="128"></input>
        </div>
        <div>
          <button id="create-or-load-model" disabled="true">Create or load model</button>
          <button id="delete-model" disabled="true">Delete existing model</button>
        </div>
      </div>

      <div class="horizontal-sections">
        <div class="monospace">
          <span class="input-title">Examples per epoch:</span>
          <input class="monospace" id="examples-per-epoch" value="2048"></input>
        </div>
        <div class="monospace">
          <span class="input-title">Batch size:</span>
          <input class="monospace" id="batch-size" value="128"></input>
        </div>
        <div class="monospace">
          <span class="input-title">Epochs:</span>
          <input class="monospace" id="epochs" value="5"></input>
        </div>
        <div class="monospace">
          <span class="input-title">Validation spilt:</span>
          <input class="monospace" id="validation-split" value="0.0625"></input>
        </div>
        <div class="monospace">
          <span class="input-title">Learning rate:</span>
          <input class="monospace" id="learning-rate" value="1e-2"></input>
        </div>
        <div>
          <button id="train-model" disabled="true">Train model</button>
        </div>
        <div class="horizontal-sections">
          <div class="canvases" id="loss-canvas"></div>
        </div>
      </div>
    </div>

    <div class="vertical-sections">
      <div class="monospace">
        <span class="input-title">Generation length:</span>
        <input class="monospace" id="generate-length" value="200"></input>
      </div>
      <div class="monospace">
        <span class="input-title">Generation temperature:</span>
        <input class="monospace" id="temperature" value="0.75"></input>
      </div>
      <div>
        <button id="generate-text" disabled="true">Generate text</button>
        <span id="text-generation-status"></span>
      </div>
      <div>
          <span class="input-title">Seed text:</span>
          <textarea class="monospace" id="seed-text" value="" rows="4"></textarea>
        </div>
      <div>
        <span class="input-title">Generated text:</span>
        <textarea class="monospace" id="generated-text" readonly="true" value="" rows="10"></textarea>
      </div>
    </div>
  </div>

</body>

<script src="index.js"></script>
